Q = require 'q'
request = require 'request'

module.exports = 
  requestPost: (url, params)->
    defered = Q.defer()
    options =
      url:url
      method:'POST'
      headers:[
        {
          name:'content-type',
          value:'application/json'
        }
      ]
      json:true
      body:params
      # timeout:80000
    request.post options,(err,res,body)->
      if err
        defered.reject err
      if 200 is res?.statusCode and body
        result = body
        defered.resolve result
    return defered.promise